import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * I am the arabian Swordsman!
 * @author Hugo Armando Rodríguez Flores 
 * @version May 24th 2013
 */
public class Swordsman extends Jefe
{
    /**
     * Defines the Swordman properties
     */
    public Swordsman()
    {
        super();
        super.storeImages(17, "swo");
    }
    
    public void act() 
    {
        if (!this.getRemoveFlag())
        {
            super.thomasDetection(20);
            super.attackTiming(33);
            super.act();
        }
        else
            super.removeEnemy();
    }
    
    /**
     * Defines how the Swordsman will move.
     */
    public void movementAnimation()
    {
        super.reverseImages();
        switch (super.getMoveCounter())
        {
            case 0: this.setImage(super.getElement(0));  super.moveCounterIncr();  break;
            case 2: this.setImage(super.getElement(1));  super.moveCounterIncr();  break;
            case 4: this.setImage(super.getElement(2));  super.moveCounterIncr();  break;
            case 6: this.setImage(super.getElement(3));  super.moveCounterIncr();  break;
            case 8: this.setImage(super.getElement(4));  super.moveCounterIncr();  break;
            case 10: this.setImage(super.getElement(5));  super.moveCounterIncr();  break;
            case 12: this.setImage(super.getElement(6));  super.moveCounterIncr();  break;
            case 14: this.setImage(super.getElement(7));  super.moveCounterIncr();  break;
            case 16: this.setImage(super.getElement(8));  super.moveCounterIncr();  break;
            case 18: this.setImage(super.getElement(9));  super.moveCounterIncr();  break;
            case 20: this.setImage(super.getElement(10));  super.moveCounterIncr();  break;
            case 22: this.setImage(super.getElement(11));  super.moveCounterIncr();  break;
            case 24:     super.setMoveCounter(0);  break;
            default: super.moveCounterIncr();
        }
    }
    
    /**
     * Defines how the arabian Sworsman will attack Thomas.
     */
    public void attack() 
    {
        if (!super.getAttackedFlag())
            switch(super.getAttackCounter())
            {
                case 0: this.setImage(super.getElement(12));  super.attackCounterIncr(); break;
                case 8: this.setImage(super.getElement(13));  super.attackCounterIncr(); break;
                case 16: this.setImage(super.getElement(14));  super.attackCounterIncr(); break;
                case 24: this.setImage(super.getElement(15));  super.attackCounterIncr(); break;
                case 32: this.setImage(super.getElement(16));  super.attackCounterIncr(); super.inflictDamage(20);  break;
                case 40: super.setAttackCounter(0); super.setAttackedFlag(true);    break;
                default: super.attackCounterIncr();
            }
    }  
}
